package com.datasure.cloudsure.redis.controller;

import com.datasure.cloudsure.redis.annotation.CachePut;
import com.datasure.cloudsure.redis.entity.Hobby;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @创建人: 放生
 * @创建时间: 2022/4/21
 * @描述:
 */
@RestController
public class TestController {


    @CachePut(cacheKey = "#hobby.fruit",expire = 30000,dsName = "redisDataSoure1")
    @PostMapping("/getOrSaveData/ds01")
    public Object getOrSaveDataFromCacheDs01(@RequestBody Hobby hobby){
        List<String> fruit = List.of("香蕉01", "桔子01", "苹果01", "榴莲01");
        System.out.println("未命中缓存");
        return fruit;

    }

    
    @CachePut(cacheKey = "#hobby.fruit",expire = 30000,dsName = "redisDataSoure2")
    @PostMapping("/getOrSaveData/ds02")
    public Object getOrSaveDataFromCacheDs02(@RequestBody Hobby hobby){
        List<String> fruit = List.of("香蕉02", "桔子02", "苹果02", "榴莲02");
        System.out.println("未命中缓存");
        return fruit;

    }





}
